import { $http } from '@/utils';
import { $ResponseCode } from '@/utils/const/env';
export const Login = {
    login: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/login', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    wechatMPCode: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/wechatMPCode', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    vcode: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/vcode', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    wechatMP: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/wechatMP', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
    getVcode: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/getVcode', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请后再试' });
            })
        })
    },
    wechatLogin: (data: any) => {
        return new Promise((resolve, reject) => {
            $http.post('Login/wechatLogin', { data }).then((res: any) => {
                if (res.code === $ResponseCode.SUCCESS) {
                    resolve(res);
                } else {
                    reject(res);
                }
            }).catch(() => {
                reject({ msg: '服务器繁忙，请稍后再试' });
            })
        })
    },
};